package com.rh.number.enums;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

// 在com.rh.number.enums包下创建SystemRole.java
public enum SystemRole {
    SYSTEM_USER,
    ADMIN_USER;

    // 将枚举角色转换为Spring Security权限对象
    public GrantedAuthority toAuthority() {
        // 自动添加 ROLE_ 前缀（Spring Security规范）
        return new SimpleGrantedAuthority("ROLE_" + this.name());
    }
}